    <%-- 
    Document   : index
    Created on : 24-mag-2011, 15.45.46
    Author     : dav
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<jsp:useBean id="con" scope="application" class="MyBean.Connessione" />
<!DOCTYPE html>
<html>
    <head>
        <link href="style.css" rel="stylesheet" type="text/css">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Biblioteca</title>   
    </head>
    <body>
        <div id="container">
        <div id="header">Biblioteca Online</div>

            <div id="menu">
                <jsp:include page="menu.jsp" flush="true"/>
            </div>
            
            <div id="content">
                <center><h2>Ricerca libro</h2></center>
                <form action="ricerca.jsp" method="POST" onSubmit="return controlloInserimento();">
                    <input type="hidden" name="cercato" value="1">
                     <center> 
                    <table>
                        <tr>
                            <td>
                                Titolo : 
                            </td>
                            <td>
                                <input type="text" name="titolo" id="a"></input>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Autore : 
                            </td>
                            <td>
                                <input type="text" name="autore" id="b"></input>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                Editore : 
                            </td>
                            <td>
                                <input type="text" name="editore" id="c"></input>
                            </td>
                        </tr>
                        <tr>    
                            <td>
                                Anno : 
                            </td>
                            <td>
                                <input type="text" name="anno" id="d"></input>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2"><center><input type="submit" value="Cerca"></center></td>
                        </tr>
                    </table>
                    </center>
                </form>
                <script type="text/javascript">
                    function controlloInserimento(){
                        var a = document.getElementById('a').value;
                        var b = document.getElementById('b').value;
                        var c = document.getElementById('c').value;
                        var d = document.getElementById('d').value;
                        
                        if(a!="" || b!="" || c!="" || d!=""){
                            return true;
                        }else{
                            alert("Almeno un campo deve essere compilato")
                            return false;
                        }
                        return false;
                    }
                </script>
                <% if(request.getParameter("cercato")!=null && session.getAttribute("username")!=null){
                    %>
                <jsp:include page="cRicerca?action=p" flush="true"/>
                <%
                }else if(request.getParameter("cercato")!=null && session.getAttribute("username")==null){
                    %>
                <jsp:include page="cRicerca?action=r" flush="true"/>
                   <%
                }
                %>
                </div>    
        </div>
        
    </body>
</html>
